package com.shop2cn.app.im.testcase;

import java.util.Date;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.google.gson.JsonObject;
import com.shop2cn.app.im.parameter.GetDistributorNotifyListBean;
import com.shop2cn.app.im.service.GetDistributorNotifyListCall;
import com.ymatou.iapi.notify.parameter.SendNotifyBean;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.AuthCallServiceV2;
import com.ymttest.business.service.NotifyCallService;
/**
*分销员通知列表Test
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_GetDistributorNotifyList{
	private static GetDistributorNotifyListBean getdistributornotifylistBean;
	private static GetDistributorNotifyListCall getdistributornotifylistCall;
	private static int sellerId ;
	private static String token ;
	
	@BeforeClass
	public static void setUp() {
		try {
			sellerId =500987016;
			token=AuthCallServiceV2.createToken(sellerId, "app");
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		Logger.createResultFile("分销员通知列表Test");
	}

	@Before
	public void caseUp() {
		getdistributornotifylistBean=new GetDistributorNotifyListBean();
		getdistributornotifylistCall=new GetDistributorNotifyListCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(getdistributornotifylistCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetDistributorNotifyList_001() {
		Logger.start(true,"正确数据，成功");
		try {
			//disconf配置fromUserId = 19000300
			//分销员通知
			SendNotifyBean sendNotifyBean = NotifyCallService.initSendNotify(NotifyCallService.SHOP2CN_FROM_NOTIFY,sellerId);
			NotifyCallService.SendNotify(sendNotifyBean);
			getdistributornotifylistBean.setLongTimeline(0l);
			getdistributornotifylistBean.setMessageCount(1);
			getdistributornotifylistCall.setData(getdistributornotifylistBean);
			String head="accesstoken="+token;
			getdistributornotifylistCall.addHeader("ymt-pars", head);
			getdistributornotifylistCall.callService();
			Logger.verifyEquals("200", getdistributornotifylistCall.getString("code"), "验证code");
			JsonObject notify = getdistributornotifylistCall.getJsonObject().getAsJsonArray("notifyList").get(0).getAsJsonObject();
			Logger.verifyEquals(false,notify.get("isRead").getAsBoolean(),"验证isRead");
			Logger.verifyEquals(sendNotifyBean.getMessage(),notify.get("message").getAsString(), "验证message");
			Logger.verifyEquals(NotifyCallService.SHOP2CN_FROM_NOTIFY,notify.get("msgFromId").getAsInt(), "验证msgFromId");
		} catch (Exception e) {
			
			Logger.fail(e);
		}
	}
}